#include <stdio.h>
#include <assert.h>

typedef unsigned packet_t;

int xbyte(packet_t x, int bytenum){
    return (int) (x << ((3 - bytenum) << 3)) >> 24;
}

int main(){
    assert(xbyte(0x12345678, 1) == 0x56);
    assert(xbyte(0x1234FFFF, 1) == -1);

    return 0;
}
